<template>
  <div class="datav_map">
    <div class="datav_map_img">
      <img src="./../../assets/img/index/datav_count_1.png" alt />
    </div>
    <div class="datav_map_content">
      <div class="datav_part_title">
        <span>佣金发放占比</span>
      </div>
      <div class="datav_part_body">
        <div class="datav_part_left">
          <p>总佣金额：{{ $fnc.toFixedZ(commission.money) }}元</p>
          <p>分销奖励：{{ $fnc.toFixedZ(commission.money_1) }}元</p>
          <p>团队奖励：{{ $fnc.toFixedZ(commission.money_2) }}元</p>
          <p>区域代理：{{ $fnc.toFixedZ(commission.money_3) }}元</p>
          <!-- <p>分红公排：{{$fnc.toFixedZ(commission.money_4)}}元</p> -->
        </div>
        <div class="datav_part_right">
          <div id="datav_count2" style="width:100%;height:100%;"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "datav_map",
  data () {
    return {};
  },
  props: {
    commission: {
      type: Object,
      default: {}
    }
  },
  components: {},
  mounted () {
    var that = this;
    this.$nextTick(() => {
      that.get_count();
    });
  },
  methods: {
    get_count () {
      var colorList = [
        "#034079",
        "#49DFF0",
        "#DFB141",
        "#00FEB5",
        "#7081DB",
        "#FDFEFF",
        "#2385E0"
      ];
      var option = {
        backgroundColor: "transparent",
        tooltip: {
          trigger: "item",
          formatter: "{b}: {c} ({d}%)"
        },
        grid: {
          top: "1%",
          containLabel: true
        },
        title: {
          text: this.commission.money,
          subtext: "总佣金额",
          x: "center",
          y: "center",
          textStyle: {
            fontSize: 14,
            fontWeight: "normal",
            color: "#00FFFF"
          },
          subtextStyle: {
            fontSize: 12,
            fontWeight: "normal",
            align: "center",
            color: "#CCCCCC"
          }
        },
        // legend: {
        //     bottom: "0%",
        //     data: ["总提现额", "总佣金额", "总成本额", "已拨佣金"],
        //     textStyle: {
        //         color: "#fff",
        //         fontSize: "6px"
        //     }
        // },
        series: [
          {
            type: "pie",
            radius: ["40%", "60%"],
            clockwise: false,
            z: 5,
            itemStyle: {
              normal: {
                color: function (params) {
                  // build a color map as your need.
                  return colorList[params.dataIndex];
                },
                shadowBlur: 20,
                shadowColor: "rgba(0, 0, 0, 0.3)"
              }
            },
            label: {
              normal: {
                // show: false, //是否显示
                formatter: "{d|{b}}\n{hr|}\n{d|({d}%)}",
                rich: {
                  b: {
                    fontSize: 12,
                    color: "#fff",
                    align: "left",
                    padding: 4
                  },
                  hr: {
                    //		                            borderColor: '#12EABE',
                    width: "100%",
                    borderWidth: 1,
                    height: 0
                  },
                  d: {
                    fontSize: 12,
                    color: "#fff",
                    align: "left",
                    padding: 1
                  },
                  c: {
                    fontSize: 12,
                    color: "#fff",
                    align: "center"
                    //		                            padding: 4
                  }
                }
              }
            },

            // labelLine: {
            //     normal: {
            //         length: 22,
            //         length2: 0,
            //         lineStyle: {
            //             width: 2
            //         }
            //     }
            // },
            data: [
              {
                value: this.commission.bili_1,
                name: "分销奖励"
              },
              {
                value: this.commission.bili_2,
                name: "团队奖励"
              },
              {
                value: this.commission.bili_3,
                name: "区域代理"
              }
              // {
              //   value: this.commission.bili_4,
              //   name: "分红公排"
              // }
            ]
          }
        ]
      };
      var myChart = this.$echarts.init(document.getElementById("datav_count2"));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    }
  }
};
</script>
<style lang="less" scoped>
.datav_map {
  width: 100%;
  position: relative;
  .datav_map_img {
    width: 100%;
    img {
      //   width: 100%;
      height: 100%;
    }
  }
  .datav_map_content {
    width: 100%;
    padding: 10px 20px 20px 20px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-flow: column;

    .datav_part_title {
      width: 100%;
    }
    .datav_part_body {
      width: 100%;
      height: 100%;
      flex: 1;
      display: flex;
      flex-wrap: nowrap;
      justify-content: space-between;
      align-items: flex-start;
      // padding-top: 20px;
      .datav_part_left {
        width: 40%;
        height: 100%;
        display: flex;
        flex-flow: column;
        justify-content: space-evenly;
        align-items: flex-start;
        p {
          font-size: 16px;
          color: #ffffff;
          font-weight: bold;
          @media only screen and (min-width: 1680px) and (max-width: 1920px) {
            font-size: 16px;
          }
          @media only screen and (min-width: 1440px) and (max-width: 1680px) {
            font-size: 14px;
          }
          @media only screen and (min-width: 1024px) and (max-width: 1440px) {
            font-size: 12px;
          }
          @media only screen and (max-width: 1024px) {
            font-size: 10px;
          }
        }
      }
      .datav_part_right {
        width: 60%;
        height: 100%;
      }
    }
  }
}
</style>
